package sysuser

import (
	"context"
	"jinrigaoping/rpc/sys/sys"

	"jinrigaoping/api/superadmin/internal/svc"
	"jinrigaoping/api/superadmin/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SysUserUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSysUserUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SysUserUpdateLogic {
	return &SysUserUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SysUserUpdateLogic) SysUserUpdate(req *types.SysUserUpdateReq) (resp *types.SysUserUpdateRes, err error) {

	_, err = l.svcCtx.SysRpc.SysUserUpdate(l.ctx, &sys.SysUserUpdateReq{
		Id:       req.Id,
		RoleId:   req.RoleId,
		Nickname: req.Nickname,
		Phone:    req.Phone,
		Email:    req.Email,
		Brief:    req.Brief,
	})
	if err != nil {
		logx.Errorf("l.svcCtx.SysRpc.SysUserUpdate req: %v error: %v", req, err)
		return nil, err
	}
	return
}
